package com.lzx.lizhenxing.common.utils;

/**
 * 通过ThreadLocal处理用户信息
 */
public class UserUtils {

    // 用来存储用户id
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    /**
     * 向ThreadLocal中存储用户id
     *
     * @param uid
     */
    public static void setUser(Long uid) {
        threadLocal.set(uid);
    }

    /**
     * 获取用户id
     *
     * @return
     */
    public static Long getUser() {
        return threadLocal.get();
    }

    /**
     * 删除用户id
     */
    public static void removeUser() {
        threadLocal.remove();
    }
}
